<template>
	<el-drawer :title="titleMap[mode]" v-model="visible" :size="1400" destroy-on-close @closed="$emit('closed')">
		<el-container v-loading="loading">
			<el-main style="padding:0 20px 20px 20px">
				<el-form ref="ruleForm" :model="form" :rules="rules" label-width="100px">
					<el-form-item label="素材类目" prop="category_id">
						<blCategory style="width: 400px;" v-model="form.category_id" model="Media" />
					</el-form-item>
					<el-form-item label="上传素材">
						<sc-oss-upload-file :limit="99" drag :maxSize="100*1024*1024">
							<el-icon class="el-icon--upload"><el-icon-upload-filled /></el-icon>
							<div class="el-upload__text">
								拖拽文件到此处或者 <em>点击上传</em>
							</div>
						</sc-oss-upload-file>
					</el-form-item>

					<div style="height:400px">
						&nbsp;
					</div>

				</el-form>
			</el-main>
			<el-footer>
				<el-button type="primary" :loading="isSaveing" @click="submit">保存</el-button>
				<el-button @click="visible=false">取消</el-button>
			</el-footer>
		</el-container>
	</el-drawer>
</template>

<script>
	var _this;

	import {
		defineAsyncComponent
	} from 'vue';
	const scEditor = defineAsyncComponent(() => import('@/components/scEditor'));


	export default {
		emits: ['success', 'closed'],
		components: {
			scEditor
		},
		data() {
			return {
				loading: false,
				mode: "add",
				titleMap: {
					add: '上传素材',
					edit: '查看素材'
				},
				form: {
					id: '',
					cg_name: "",
					category_id: null,
					cg_description: "",
					cg_type: "SQL",
					cg_status: "pending",
					is_disabled: true,
					cg_code: "",
					cg_cron: "0 5 0 * * ?",
					cg_pre_oper: []
				},
				rules: {

				},
				visible: false,
				isSaveing: false,
				apiObj: null,
			}
		},
		mounted() {
			_this = this;
		},
		methods: {
			getNextCronTime(str) {
				// return getNextCronTime(str);
			},
			success(res) {
				return true;
			},
			//显示
			open(data) {
				if (data) {
					this.mode = data;
				}
				this.visible = true;
				this.$nextTick(() => {
					if (this.mode == 'add') {

					}
				})
				return this;
			},
			//表单提交方法
			submit() {
				this.isSaveing = true;
				this.isSaveing = false;
				this.visible = false;
			},
			//表单注入数据
			setData(data) {
				this.loading = true

				if (!data.id) {
					if (data.category_id) {
						this.form.category_id = data.category_id
					}
					this.loading = false
					return;
				}

				const params = {
					id: data.id
				}
				setTimeout(async () => {
					var res = await this.$API.system.custGroup.show.get(params)
					this.loading = false
					this.form = res.data
				}, 0)
			}
		}
	}
</script>

<style>
	.custom-empty {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		background: #8c939d;
		border-radius: 5px;
	}

	.custom-empty i {
		font-size: 30px;
		color: #fff;
	}

	.custom-empty p {
		font-size: 12px;
		font-weight: normal;
		color: #fff;
		margin-top: 10px;
	}

	.class_title {
		padding-left: 18px;
		font-size: 18px;
		background-color: #f4f9ff;
		text-align: left;
		width: 100%;
	}

	.section-title {
		font-size: 14px;
		font-weight: 400;
		border-left: 5px solid var(--el-color-primary);
		padding-left: 10px;
		color: var(--el-text-color-regular);
	}
</style>
